/**
 * 下载
 */
 (function (doc, win) {                             //size
	var docEl = doc.documentElement,
		docBody = doc.body,
		resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
		recalc = function () {
			var clientWidth = docEl.clientWidth;
			if (!clientWidth) return;
			clientWidth = Math.min(Math.max(clientWidth, 320), 640);
			docEl.style.fontSize = 100 * (clientWidth / 320) + 'px';
		};
	if (!doc.addEventListener) return;
	docEl && recalc();
	doc.addEventListener('DOMContentLoaded', recalc, false);
	win.addEventListener(resizeEvt, recalc, false);
})(document, window);

//获取参数
function UrlSearch(){
	 var name,value;
	 var str=location.href; //取得整个地址栏;
	 var num=str.indexOf("?")
	 str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]
	 var arr=str.split("&"); //各个参数放到数组里
	 for(var i=0;i < arr.length;i++){
		num=arr[i].indexOf("=");
		if(num>0){
			 name=arr[i].substring(0,num);
			 value=arr[i].substr(num+1);
			 this[name]=value;
		}
	}
}

//时间戳转换
function getMyDate(str){
	 var oDate = new Date(str),
	 oYear = oDate.getFullYear(),
	 oMonth = oDate.getMonth()+1,
	 oDay = oDate.getDate(),
	 oHour = oDate.getHours(),
	 oMin = oDate.getMinutes(),
	 oSen = oDate.getSeconds(),
	 oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最后拼接时间
	 return oTime;
 };
 //补0操作
 function getzf(num){
     if(parseInt(num) < 10){
         num = '0'+num;
     }
     return num;
 }

$(document).ready(function() {      //下载链接
	     var isiPad = /iPad/i.test(navigator.userAgent);
	     var isiPhone = /iPhone|iPod/i.test(navigator.userAgent);
	     var issAndroid = /Android/i.test(navigator.userAgent);
	     var isWeixin = /MicroMessenger/i.test(navigator.userAgent);
	     var isQQ = /QQ/i.test(navigator.userAgent);
	     var isIOS = (isiPad || isiPhone);
	     var isWeibo = /Weibo/i.test(navigator.userAgent);
	     //下载
	     function set_down_url() {
	         //设置下载按钮
	         var down_url = '';
	         if (isWeixin) {
	             if (issAndroid) {
	                 down_url = 'http://ww.wuyoutianxia.com/apk/app-release.apk';
	             }else if (isiPhone) {
	                 down_url = 'http://itunes.apple.com/app/id1296187722';
	             }else if (isiPad) {
	                 down_url = 'http://itunes.apple.com/app/id1296187722';
	             }else{
	                 down_url = 'http://ww.wuyoutianxia.com/wyadm/about.html';
	             }
	         }else if (isQQ) {
	             if (issAndroid) {
	                 down_url = 'http://ww.wuyoutianxia.com/apk/app-release.apk';
	             }else if (isiPhone) {
	                 down_url = 'http://itunes.apple.com/app/id1296187722';
	             }else if (isiPad) {
	                 down_url = 'http://itunes.apple.com/app/id1296187722';
	             }else{
	                 down_url = 'http://ww.wuyoutianxia.com/wyadm/about.html';
	             }
	         }else{
	             if (issAndroid) {
	                 down_url = 'http://ww.wuyoutianxia.com/apk/app-release.apk';
	             }else if (isiPhone) {
	                 down_url = 'http://itunes.apple.com/app/id1296187722';
	             }else if (isiPad) {
	                 down_url = 'http://itunes.apple.com/app/id1296187722';
	             }else{
	                 down_url = 'http://ww.wuyoutianxia.com/wyadm/about.html';
	             }
	         }
	         $('#dLoad').attr('href', down_url);
			 $('#dlod').attr('href', down_url);
	     }
		     //下载开关
		     set_down_url();
		    //  $(".closes").click(function(event) {
		    //  	$(".dl").slideUp();
		    //  	$(".hei4").hide();
		    //  });
			 if (issAndroid) {
				 if (isWeixin || isQQ) {
					 $("#dlod").click(function(event) {
        		     	$(".bg").show();
        		     });
				 }
			 }

	     });
